﻿Imports BUS
Imports DTO
Public Class frmTHEMSANPHAM


    Dim mhbus As MatHangBUS = New MatHangBUS

    Private Sub btn_them_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_them.Click
        If txt_giaban.Text <> "" And txt_tenhang.Text <> "" Then
            themsp()
            LoadDsMatHang()
            MessageBox.Show("Đã Thêm Thành Công!")
        Else
            MessageBox.Show("Xin Nhap Day Du Thong Tin!", "Thông Báo")
        End If

    End Sub


    Private Sub themsp()

        Dim spdto As New MatHangDTO()
        spdto.TenSP = txt_tenhang.Text
        spdto.NgaySanXuat = dtp_ngasx.Value
        spdto.MaLoai = cbb_maloia.SelectedValue
        spdto.GiaBan = txt_giaban.Text
        MatHangBUS.ThemSP(spdto)
    End Sub
     

    Private Sub frmTHEMSANPHAM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadDsMatHang()
        LoadMaloai()
    End Sub

    Private Sub LoadDsMatHang()
        Dim dt As DataTable = New DataTable
        dt = mhbus.LoadMH()
        DataGridView1.DataSource = dt
    End Sub

    Private Sub LoadMaloai()
        cbb_maloia.DataSource = LoaiBUS.LayTatCaTT()
        cbb_maloia.DisplayMember = "TenLoai"
        cbb_maloia.ValueMember = "MaLoai"

    End Sub

    Private Sub btn_thoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_thoat.Click
        Me.Close()
    End Sub

    Private Sub xoa()

    End Sub

    Private Sub btn_xoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub btn_nhaplai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_nhaplai.Click
        txt_giaban.Text = ""
        txt_tenhang.Text = ""
        dtp_ngasx.Text = ""
        cbb_maloia.Text = ""
    End Sub

    Private Sub btn_datsp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_datsp.Click
        frmHOADON.Show()
        Me.Hide()
    End Sub
End Class